package com.atguigu.gmall.item.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: RedissonConfiguration
 * Package: com.atguigu.gmall.item.config
 * Description:
 *
 * @Author ltystart
 * @Create 2025/8/27 22:32
 * @Version 1.0
 */
@Configuration
public class RedissonConfiguration {
    @Autowired
    private RedisProperties redisProperties;

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer().setAddress(
                "redis://" + redisProperties.getHost() + ":" + redisProperties.getPort()
        ).setPassword(redisProperties.getPassword());
        //修改看门狗时间
//        config.setLockWatchdogTimeout()
        //创建Redisson客户端
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
